#pragma once

#include "kcmd.h"    //Command
#include "kconfig.h" //k_int
#include "ktypes.h"  //KType
#include "ktoken.h"  //TokenType

#include <vector>
#include <stack>

enum ENUM_FUNC
{
	FUNC_abs,
	FUNC_sqrt,
	FUNC_sin,
	FUNC_cos,
	FUNC_tan,
	FUNC_asin,
	FUNC_acos,
	FUNC_atan,
	FUNC_chr,
	FUNC_asc,
	FUNC_len,
	FUNC_left,
	FUNC_mid,
	FUNC_right,
	FUNC_iif,
	FUNC__tape,
	FUNC__stack,
	FUNC__pop,
	FUNC__peek
};

void AnalyseSemantics(std::vector<Command> &cmds);

void PerformTypeCheck(Command &cmd);

KType DeduceExpressionType(const Command &cmd, int startIndex);

void DeduceFunctionType(std::stack<KType> &tstack, const Token &t);

void AccumulatePC(const Command &cmd);

inline KType TranslateType(TokenType tt)
{
	return (KType)(tt - TOK_INT);
}
